package net.osweb.core.fw.jms;

import javax.jms.Message;
import javax.jms.MessageListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jms.core.JmsTemplate;

/**
 * @author hgg
 * 消息监听的基类
 */
public abstract class BaseMessageListener implements MessageListener {
	protected final Log log = LogFactory.getLog(getClass());
	private JmsTemplate jmsTemplate;
	public void setJmsTemplate(JmsTemplate jmsTemplate) {
		this.jmsTemplate = jmsTemplate;
	}
	
	public JmsTemplate getJmsTemplate() {
		return jmsTemplate;
	}

	public void onMessage(Message message) {
		if(log.isDebugEnabled())
			log.debug("Message   Listener   begin....");
		execute(message);
		if(log.isDebugEnabled())
			log.debug("Have received a message: " + message);
	}
	
	public abstract void execute(Message message);
}
